

public class BoardPathBoxesMove implements Comparable<BoardPathBoxesMove>
{
	
	public static enum BeginDirection
	{
		Forward,
		Backwards;
	}

	public BoardImplFast board;
	
	public BeginDirection beginDirection;
	public VisitedEntryBoxMove lastVisitedEntry;
	
	public int calculatedHeuristic;
	
	public DistanceCache distanceCache;

	public BoardPathBoxesMove( BoardImplFast board, BeginDirection beginDirection, 
			VisitedEntryBoxMove lastVisitedEntry, DistanceCache distanceCache )
	{
		this.board = board;

		this.beginDirection = beginDirection;
		
//		this.boxManhattanDistanceMatrix = boxManhattanDistanceMatrix;
		
		this.lastVisitedEntry = lastVisitedEntry;
		
		this.distanceCache = distanceCache;
		
		calculatedHeuristic = aStarHeuristic();
		
	}
	

	@Override
	public int compareTo(BoardPathBoxesMove arg0) 
	{
//		int refDepth = arg0.getDepthLevel();
//		int selfDepth = this.getDepthLevel();
		
		
			
			int ref = arg0.calculatedHeuristic;
			int self = this.calculatedHeuristic;
			
			if ( self < ref )
			{
				return -1;
			}
			else if ( self > ref )
			{
				return 1;
			}
			else
			{
				return 0;
//				return Integer.parseInt(path);
//				return aStarHeuristic();
			}
			
//		}
	}
	

	public int aStarHeuristic()
	{	
		if ( board.isFinished() )
		{
			return Integer.MIN_VALUE;
		}
		
		Cord[] goals = board.getGoals();
		Cord[] boxes = board.getBoxes();
		Cord player = board.getPlayer();
		

		int score = 0;

		

//		score += distanceCache.minimumPlayerDistance(board, player, boxes)^2;
		score += distanceCache.minimumPlayerDistance(board, player, boxes);
		
		for ( Cord box : boxes )
		{

			score += distanceCache.minimumBoxDistance( board, box, goals );
			
		}
		
		
		
//		score += minimumPathFromPlayer;
		
//		System.out.println(score);
		
		return score;
		
//		return 0;
	}
}